package com.example.lightenergypolymerize.task;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.example.lightenergypolymerize.entity.User;
import com.example.lightenergypolymerize.service.IUserService;
import com.xxl.job.core.handler.annotation.XxlJob;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class TimedTask {
    @Value("${system.user.user-count}")
    private Integer useCount;
    @Resource
    private IUserService userService;
    /**
     * 重置用户使用次数定时任务
     */
    @XxlJob("resetUserUseCount")
    public void resetUserUseCount() {
        UpdateWrapper<User> wrapper = new UpdateWrapper<>();
        wrapper.set("usecount", useCount);
        if(!userService.update(wrapper)) {
            //调用通知中心通知相关负责人排查和解决问题
        }
    }
}
